<?php
/**
 * Created by PhpStorm.
 * User: xiangfeng
 * Date: 2022/4/11
 * Time: 8:07 AM
 */

namespace app\api\validate;


use think\Validate;

/**
 * Class UserValidate
 * @package app\api\validate
 */
class UserValidate extends Validate
{
    protected $regex = ['phone' => '/^1[3456789]\d{9}$/'];

    protected $rule = [
        'phone' => 'require|regex:phone',
        'uname' => 'require|max:10',
        'birthday' => 'require|max:20',
        'college_name' => 'require|max:50',
        'college_dep_name' => 'require|max:50',
        'join_year' => 'require|max:50',
        'join_type' => 'require|max:50',
        'working_unit' => 'require|max:100',
        'email' => 'require|max:50',
        'image_list' => 'require|array',
        'introduce' => 'require|max:255',
        'openid' => 'require',
        'avatar' => 'require',
        'js_phone_code' => 'require'
    ];

    protected $message = [
        'phone.require' => '手机号必填',
        'phone.regex' => '手机号格式错误',
        'uname.require' => '姓名必填',
        'uname.max' => '姓名长度必填10',
        'birthday.require' => '生日必填',
        'college_name.require' => '毕业院校必填',
        'join_year.require' => '入校年份必填',
        'join_type.require' => '入校类型必填',
        'working_unit.require' => '在职单位必填',
        'email.require' => '邮箱必填',
        'avatar.require' => '个人照片必填',
        'image_list.require' => '生活照片必填',
        'introduce.require' => '自我介绍必填',
        'introduce.max' => '自我介绍长度不能超过 100',
    ];

    protected $scene = [
        'update' => [
            'uname',
            'birthday',
            'college_name',
            'join_year',
            'join_type',
            'working_unit',
            'email',
            'image_list',
            'introduce',
        ],
        'add' => [
            'uname',
            'birthday',
            'college_name',
            'join_year',
            'join_type',
            'working_unit',
            'email',
            'image_list',
            'introduce',
            'openid',
            'avatar',
            'phone'
        ],
    ];
}